Here's an overview of all fields and functions in the Subsession class:
- The
paying_round
is set as a random round between 1 andnum_rounds
.- The order of questions is randomized for each player.
- The player's :ref:`carbon_ref`, :ref:`car_miles_ref` and :ref:`bonus_ref` fields are initialized for all rounds.
- The
paying_round
is the round where the player's payoff is calculated ifrandom_payoff = True
. See :ref:`random_payoff`- A player's saved emission in the
paying_round
is added to thesum_saved_emission
field ifrandom_saved_emission = True
. See :ref:`random_emission`
- The
sum_saved_emission
field is the sum of thesaved_emission
player field for all players.- The sum is either calculated across the
paying_round
or across all rounds depending on the :ref:`random_emission` field.- The field is used as an input in the :ref:`mail_ref` function.
- Excludes all players that ar seen as bots. See :ref:`bot_criteria_ref`
- The
set_sum_saved_emission()
function sets thesum_saved_emission
field.- Checks if a player is a bot. See :ref:`bot_criteria_ref`
- If a player is not a bot then the total
saved_emission
of all players is added to thesum_saved_emission
(Either across the paying round or all rounds).- A player has to finish all rounds of the CET, so that the correct data is available. Therefore, this function is only called in the last round of the CET. See :ref:`exp_page`
all_players_finished
is a Boolean field that turnsTrue
once all players have finished the CET.
set_all_players_finished()
calculates how many players in total have finished the CET (sum_finished
).- If
sum_finished
= Number of participants then theall_players_finished
field turnsTrue
.- This function is only called once (for each player): When the player hits the "Next" button on the :ref:`results`.
- The
helpful_prints()
function prints helpful information about the current state of many player and subsession fields to the terminal.- The function can be extended at will and be used for bug fixing purposes, if a new field is added.
- The function is called in every round of the CET and when a player finishes the CET.
- The function is only useful if the number of participants is small.
The send_payment_mail()
function is used to automate carbon-emission certificate purchases for experiments with real-carbon externalities, such as the CET.
For more information see ACO Documentation.
- The modules requests and smtplib have to be imported at the top of the models.py file.
- A valid account from an SMTP service provider is needed. The credentials of the account have to be specified at the top of the function.
weight_to_donate
: A float value used to pass the amount of carbon emission that is saved by the experimental participants. The :ref:`sum_saved_emission_ref` is used for this.unit
: A string value that defines the unit of the saved carbon emission. The following values are accepted:["mg", "g", "kg", "t", "oz", "lbs", "st"]
experiment_name
: A string value that specifies the name of the experiment (e.g. "Carbon Emission Task")payment_e_mail_name
: A string that specifies the name of the person or team that receives the mailpayment_e_mail_to
: A list containing the mail addresses of all recipients . If the mail is only to be sent to one address then a single string can be passed to the function.
- The
weight_to_donate
value is converted to metric tons. The conversion is based on theunit
value.- The current CO2 price per ton for emission certificates is fetched from a price endpoint that is provided by Compensators.
- The price of the carbon-emission certificate is calculated.
- A mail is sent to all addresses within the
payment_e_mail_to
list. The mail includes the total weight of carbon-emission saved, the current price per ton for carbon-emission certificates, as well as the link to Compensators donation form with the correct price to make the carbon-emission certificate purchase. These contents can be changed at will.
- The function is called when all players have finished the CET. For an example see :ref:`results`